<?php session_start(); ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="vista/bibestilo.css" />
		<script type="text/javascript" src="controlador/jquery.js"></script>   
		<script type="text/javascript" src="controlador/materias.js"></script>
    </head>
    <?php include ("./vista/menu.inc"); ?>

    <body>

	<div id="top">
		<div id="session">
			<?php
				include('./vista/session.inc');	
			?>
		</div>
		<div id="menu">
			<ul class="lavaLamp">
			    <li><a href="index.php">Inicio</a></li>
			    <li class="current"><a href="buscar.php">Búsqueda</a></li>
			    <li><a href="#">Login</a></li>
			</ul>
		</div>

	</div>
	<div id="logo"></div>
	<div id="separador"></div>
		
		<div id='contenedor'>
		
        <div id="contenidoindex">

			<?php
					$conexion = mysql_connect(localhost,CEIC,CEICCEIC);
					mysql_select_db('BIBLIOTECA');
			?>
		
			<h3>Material relacionado a <?php echo $_GET['materia']; ?>.</h3><br>
	
			<a id ='clickg' href='' onmouseover="document.botong.src='vista/imagenes/botonguia2.png'" onmouseout="document.botong.src='vista/imagenes/botonguia.png'">
				<img name='botong' src='vista/imagenes/botonguia.png' border='0' alt='guias'/>
			</a>
			
			<div id='guia'>
			
				<?php
					$a = $_GET['materia'];

					$query = "SELECT * FROM GUIA WHERE NMATERIA='".$a."'";
					$result = mysql_query($query);				

					$querycodigo = "SELECT codigo FROM MATERIA WHERE nombre='".$a."'";
					$rescodigo = mysql_query($querycodigo);
					$rowcod = mysql_fetch_array($rescodigo, MYSQL_BOTH);
					$cmateria = $rowcod[0];

					if(!mysql_num_rows($result)) {
						echo "<p class='azul'>No hay gu&iacute;as para mostrar.</p>";
					}
					else {
					echo "<table class='guias'>";
					while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
						printf ("<tr><td><b><a href='./uploads/%s'>%s</a></b></td><td>%s bytes</td></tr>", 
						$cmateria."/".$row[1],$row['nombre'],$row['tamano']);
					}
					echo "</table>";	
					}
				?>
				
			</div>
				
			<br><br>
				
			<a id ='clickp' href='' onmouseover="document.botonp.src='vista/imagenes/botonparcial2.png'" onmouseout="document.botonp.src='vista/imagenes/botonparcial.png'">
				<img name='botonp' src='vista/imagenes/botonparcial.png' border='0' alt='parciales'/>
			</a>
			
			<div id='parcial'>
				
				<?php
					$a = $_GET['materia'];
					$query = "SELECT * FROM PARCIAL WHERE NMATERIA='".$a."'";
					$result = mysql_query($query);
					
					$querycodigo = "SELECT codigo FROM MATERIA WHERE nombre='".$a."'";
					$rescodigo = mysql_query($querycodigo);
					$rowcod = mysql_fetch_array($rescodigo, MYSQL_BOTH);
					$cmateria = $rowcod[0];

					if(!mysql_num_rows($result)) {
						echo "<p class='azul'>No hay parciales para mostrar.</p>";
					}
					else {
					echo "<table class='guias'>";
					while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
						printf ("<tr><td><b><a href='./uploads/%s'>%s</a></b></td><td>%s bytes</td></tr>", 
						$cmateria."/".$row[1],$row['nombre'],$row['tamano']);
					}
					echo "</table>";	
					}
				?>

			</div>	
			
			<br><br>
			
			<a id ='clickt' href='' onmouseover="document.botont.src='vista/imagenes/botonteorico2.png'" onmouseout="document.botont.src='vista/imagenes/botonteorico.png'">
				<img name='botont' src='vista/imagenes/botonteorico.png' border='0' alt='material teorico'/>
			</a>
			
			<div id='teorico'>
				
				<?php
					$a = $_GET['materia'];
					$query = "SELECT * FROM TEORIA WHERE NMATERIA='".$a."'";
					$result = mysql_query($query);
					
					$querycodigo = "SELECT codigo FROM MATERIA WHERE nombre='".$a."'";
					$rescodigo = mysql_query($querycodigo);
					$rowcod = mysql_fetch_array($rescodigo, MYSQL_BOTH);
					$cmateria = $rowcod[0];

					if(!mysql_num_rows($result)) {
						echo "<p class='azul'>No hay material te&oacute;rico para mostrar.</p>";
					}
					else {
					echo "<table class='guias'>";
					while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
						printf ("<tr><td><b><a href='./uploads/%s'>%s</a></b></td><td>%s bytes</td></tr>", 
						$cmateria."/".$row[1],$row['nombre'],$row['tamano']);
					}
					echo "</table>";	
					}
				?>
			
			</div>
			
			<br><br>
			
			<a id ='clicko' href='' onmouseover="document.botono.src='vista/imagenes/botonotro2.png'" onmouseout="document.botono.src='vista/imagenes/botonotro.png'">
				<img name='botono' src='vista/imagenes/botonotro.png' border='0' alt='otros'/>
			</a>
			
			<div id='otro'>
				
				<?php
					$a = $_GET['materia'];
					$query = "SELECT * FROM OTRO WHERE NMATERIA='".$a."'";
					$result = mysql_query($query);
					
					$querycodigo = "SELECT codigo FROM MATERIA WHERE nombre='".$a."'";
					$rescodigo = mysql_query($querycodigo);
					$rowcod = mysql_fetch_array($rescodigo, MYSQL_BOTH);
					$cmateria = $rowcod[0];

					if(!mysql_num_rows($result)) {
						echo "<p class='azul'>No hay material para mostrar.</p>";
					}
					else {
					echo "<table class='guias'>";
					while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
						printf ("<tr><td><b><a href='./uploads/%s'>%s</a></b></td><td>%s bytes</td></tr>", 
						$cmateria."/".$row[1],$row['nombre'],$row['tamano']);					}
					echo "</table>";	
					}
				?>
			
			</div>
	
		<br><br><br>&nbsp;&nbsp;<a href="buscar.php">Regresar a la búsqueda</a>
		
		</div>
		
        <?php include ("vista/footer.inc"); ?>
		
		</div>

    </body>
</html>
